from pymysql import connect,cursors

USERNAME = 'root'
PASSWORD = 'jisuanji2022'
HOST = '121.196.166.117'
PORT = 3306
DATABASE = 'woniunote'

def query_date(sql_str):
    try:
        conn = connect(user=USERNAME, password=PASSWORD, host=HOST, port=PORT, database=DATABASE)
        cur = conn.cursor(cursor=cursors.DictCursor)
        row_count = cur.execute(sql_str)
        conn.commit()
        result = cur.fetchall()

    except Exception as e:
        print(e)

    finally:
        cur.close()
        conn.close()
        return result